package com.woniu.login.filter;

import org.apache.shiro.web.servlet.OncePerRequestFilter;
import org.springframework.stereotype.Component;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

public class ExceptionFilter extends OncePerRequestFilter {

    public ExceptionFilter() {
        System.out.println("自定义异常");
    }

    @Override
    protected void doFilterInternal(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        System.out.println("异常处理1");
        Object exception = request.getAttribute("illegalStateException");
        if (exception != null && exception instanceof IllegalStateException) {
            // 处理异常情况
            // 这里你可以选择返回一个空的IPage，或者抛出一个自定义的异常
            System.out.println("异常处理2");
        }
    }
}
